﻿using Microsoft.Extensions.DependencyInjection;
using RuoVea.ExApp;
using RuoVea.ExConfig;
using RuoVea.ExFilter.Config;
using RuoVea.ExFilter.Model;

namespace RuoVea.ExFilter;

/// <summary>
/// ExFilter注入
/// </summary>
public class ExFilterStartup : AppStartup
{
    /// <summary>
    /// 注入
    /// </summary>
    /// <param name="services"></param>
    public void ConfigureServices(IServiceCollection services)
    {
        ExFilterOptions exFilterOptions = Appsettings.GetConfig<ExFilterOptions>("ExFilter");
        Validate(exFilterOptions);
        ExFilterConfigs.FilterOptions = exFilterOptions;
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="filterOptions"></param>
    /// <exception cref="Exception"></exception>
    private void Validate(ExFilterOptions filterOptions)
    {
        if (filterOptions.AppKeys == null)
            throw new Exception("没有设置ExFilter:AppKeys");
    }
}
